#ifndef FILEREAD_H
#define FILEREAD_H
#include <fcntl.h>
#include <stdio.h>
#include<QFile>
#include<QDebug>
#include<QString>

void fileread()
{
    QFile file("/dev/rp");
    if(file.open(QIODevice::ReadWrite | QIODevice::Text))
    {
        char buff[1024]={0};
        file.read(buff,1024);
        QString st = QString(buff);
       // ui->text_r->setText(QString(t));
        qDebug()<< "read data : " <<st;

    }
    else
    {
        qDebug("read /dev/rp error");
    }
    file.close();
}

void filewrite(QString s)
{
    QFile file("/dev/rp");
    if(file.open(QIODevice::ReadWrite | QIODevice::Text))
    {
       QByteArray res2 = s.toLatin1();//toLatin1()转为QByteArray
       file.write(res2);
    }
    else
    {
        qDebug("open /dev/rp error");
    }
    qDebug("write ok");
    file.close();
}


#endif // FILEREAD_H
